package com.stottlerhenke.simbionic.engine.parser;
import com.stottlerhenke.simbionic.api.*;
import com.stottlerhenke.simbionic.engine.core.*;

public class SB_ExpConstant extends SB_Expression {
  protected SB_Variable _constant;

  public SB_ExpConstant(float num) {
    super();
    _constant = new SB_VarFloat(num);
  }
  public SB_ExpConstant(int num){
    super();
    _constant = new SB_VarInteger(num);
  }
  public SB_ExpConstant(boolean bool){
    super();
    _constant = new SB_VarBoolean(bool);
  }
  public SB_ExpConstant(String str){
    super();
    _constant = new SB_VarString(str);
  }
  public SB_ExpConstant(float x, float y, float z){
    _constant = new SB_VarVector(x, y, z);
  }

  public SB_Variable Evaluate(SB_Entity entity, SB_ExecutionFrame contextFrame) throws SB_Exception
  {
    return _constant.Clone();
  }
  
  public String PrintTree() throws SB_Exception
  {
    if(_constant.GetType() == SB_VarType.kString)
      return new String("string(" + SB_VarString.GET_STRING(_constant) + ")");
    if(_constant.GetType() == SB_VarType.kInteger)
      return new String("integer(" + Integer.toString(SB_VarInteger.GET_INTEGER(_constant)) + ")");
    if(_constant.GetType() == SB_VarType.kFloat)
      return new String("float(" + Float.toString(SB_VarFloat.GET_FLOAT(_constant)) + ")");
    if(_constant.GetType() == SB_VarType.kBoolean)
      return new String("boolean(" + Boolean.toString(SB_VarBoolean.GET_BOOLEAN(_constant)) + ")");
    if(_constant.GetType() == SB_VarType.kVector)
      return new String("vector(" + Float.toString(SB_VarVector.GET_VECTOR(_constant).x)
                                  + Float.toString(SB_VarVector.GET_VECTOR(_constant).y)
                                  + Float.toString(SB_VarVector.GET_VECTOR(_constant).z) + ")");
    else
      return new String( "unknown type");
  }
}